import req, { RequsetOptons } from "/@/api/req";
import { FunctionItem, MenuItem, MenuSearchModel, SortParams } from "./models";
export enum Api {
  getAllFunctionsTreeByAppId = "api/system/functions/getAllFunctionsTreeByAppId",
  addAppFeature = "api/system/appFeatures/addAppFeature",
  updateAppFeature = "api/system/appFeatures/updateAppFeature",
  deleteAppFeaturesByIds = "api/system/appFeatures/deleteAppFeaturesByIds",
  addFunction = "api/system/functions/addFunction",
  updateFunction = "api/system/functions/updateFunction",
  deleteFunctionsByIds = "api/system/functions/deleteFunctionsByIds",
  saveOperation = "api/system/functions/saveOperation",
  updateFunctionDisplayOrder = "api/system/functions/updateFunctionDisplayOrder",
  getTotalFunctionsTreeByAppId = "api/system/functions/getTotalFunctionsTreeByAppId",
}

export function getAllFunctionsTreeByAppId(params: MenuSearchModel, options: RequsetOptons) {
  return req.get<MenuItem[]>(
    {
      params,
      url: Api.getAllFunctionsTreeByAppId,
    },
    options
  );
}

export function saveOperation(data: FunctionItem) {
  return req.post<boolean>({
    data,
    url: Api.saveOperation,
  });
}

export function updateFunctionDisplayOrder(data: SortParams) {
  return req.post<boolean>({
    data,
    url: Api.updateFunctionDisplayOrder,
  });
}
// export function addAppFeature() {}
// export function getAllMenu(data: GetAllMenuParam) {
//   return req.post<MenuItem[]>(
//     {
//       url: Api.getAllMenu,
//       data,
//     },
//     {
//       useGlobalLoading: false,
//     }
//   );
// }

// export function createMenu(params: MenuItem) {
//   params.label = params.name;
//   return req.post<MenuItem>({
//     data: params,
//     url: Api.menu,
//   });
// }

// export function deleteMenu(params: DeleteParams) {
//   return req.delete<boolean>({
//     data: params.ids,
//     url: Api.menu,
//   });
// }

// export function updateMenu(params: MenuItem) {
//   params.isGeneral = params.isGeneral ? 1 : 0;
//   params.label = params.name;
//   return req.put<MenuItem>({
//     data: params,
//     url: Api.menu,
//   });
// }
